{{- $context := . }}
{{- range $cert := $context.Values.ingressNginx.internal.nginxAuthTLS }}

---
apiVersion: v1
kind: Secret
metadata:
  name: ingress-nginx-{{ $cert.controllerName }}-auth-tls
  namespace: d8-ingress-nginx
  {{- include "helm_lib_module_labels" (list $context ) | nindent 2 }}
data:
  client.crt: {{ $cert.data.cert | b64enc }}
  client.key: {{ $cert.data.key | b64enc }}
---
{{/*include fake ingress for triggering config reload on certificate change*/}}
{{- $certChecksum := (printf "%s.%s" $cert.data.cert $cert.data.key) | sha256sum }}
{{ include "fake-ingress" (list $context $cert.controllerName $cert.ingressClass "client-cert" (printf "/%s" $certChecksum) )}}
{{- end }}
